<template>
  <div class="container">
    <el-container class="home-container">
      <!-- 页面头部区域 -->
      <el-header>
        <el-menu
          background-color="#475164"
          text-color="#fff"
          active-text-color="#ffd04b"
          mode="horizontal"
          router
          :default-active="$route.path"
        >
          <el-menu-item index="/welcome">
            <template slot="title">
              <span style="font-size: 20px">在线面试平台</span>
            </template>
          </el-menu-item>

          <el-menu-item index="/problems">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>题目</span>
            </template>
          </el-menu-item>

          <el-menu-item index="/interviewList">
            <i class="el-icon-phone-outline"></i>
            <span slot="title">面试</span>
          </el-menu-item>

          <el-menu-item index="/messageBoard">
            <i class="el-icon-chat-dot-round"></i>
            <span slot="title">留言</span>
          </el-menu-item>
        </el-menu>
        <el-button type="info" @click="logout">退出</el-button>
      </el-header>
      <!-- 页面主体区域 -->

      <el-main>
          <!-- 路由占位符 -->
        <router-view></router-view>
      </el-main>
      
    </el-container>
  </div>
</template>

<script>
export default {
  // 默认行为
  create() {
    this.getMenuList();
  },
  data() {
    return {
      // 当前被激活的连接
      activePath: "",
    };
  },
  methods: {
    // 登出
    logout() {
      window.sessionStorage.clear();
      this.$router.push("/login");
    },
    // 根据用户类型决定菜单，还未写完
    getMenuList() {
      userType = window.sessionStorage.getItem("userType");
    },
    // 保存菜单的激活状态
    saveNavStatus(activePath) {
      window.sessionStorage.setItem("activePath", activePath);
      this.activePath = activePath;
    },
  },
};
</script>

<style lang="less" scoped>
.container,
.home-container {
  height: 100%;
}

.el-header {
  background-color: #475164;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  font-size: 20px;
  position: -webkit-sticky;
  position: sticky; /*兼容*/
  top: 0;
  left: 0;
  z-index: 1000;
}
.el-link.el-link--info {
  color: #fff;
  font-size: 20px;
}
.el-menu {
  width: 80%;
  height: 100%;
}

.el-main {
  background-color: #fff;
}
</style>